<!--yb 2023年3月15日15:00:13-->
<!--  竞拍管理  -->
<template>
    <div>
        <el-card class="box-card1">
            <div>
                <span style="margin-right: 10px; color: #909399;">状态 &nbsp;:</span>&nbsp;
                <el-select v-model="queryGoodsInfoSelectAll.checkStatus" placeholder="全部" style="width: 120px;height: 15px;">
                <el-option
                    v-for="item in options"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value">
                </el-option>
                </el-select>
                <span style="margin-left: 30px;color: #909399;">联系人&nbsp;&nbsp;:</span>&nbsp;<el-input v-model="queryGoodsInfoSelectAll.contactName" placeholder="请输入内容" style="width: 100px;height: 15px;margin-left: 15px;"></el-input>
                <span style="margin-left: 30px;color: #909399;">联系方式&nbsp;&nbsp;:</span>&nbsp;<el-input v-model="queryGoodsInfoSelectAll.phone" placeholder="请输入内容" style="width: 100px;height: 15px;margin-left: 15px;"></el-input>
                    <span class="demonstration" style="margin-left: 30px;color: #909399;">拍卖时间&nbsp;&nbsp;:</span>
                    <el-date-picker style="margin-left: 20px;"
                      v-model="queryGoodsInfoSelectAll.time"
                      type="daterange"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期">
                    </el-date-picker>
                <el-button type="danger" plain @click="getpublishSelectAll()" style="margin-left: 80px; ">查询</el-button>
                <el-button icon="el-icon-delete" @click="resetting" style="margin-left: 40px; background-color: #d7000f;  border: 1px solid #d7000f; color:#fff ">重置</el-button>
            </div>
        </el-card>
        <el-card class="box-card2" style="margin-top: 20px;">
            <el-table :data="tableData" border style="width: 100%">
                <el-table-column prop="goodsNumber" label="竞拍编号" width="200px">
                </el-table-column>
                <el-table-column  prop="checkStatus" label="状态" width="100px" >
                  <template slot-scope="scope">
                    <span v-for="item in status" :key="item.id">
                      <span v-if="item.id == scope.row.checkStatus">{{item.value}}</span>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="goodsName" label="拍品名称" width="150px">
                </el-table-column>
                <el-table-column prop="contactName" label="联系人" width="80px">
                </el-table-column>
                <el-table-column prop="phone" label="联系方式" width="120px">
                </el-table-column>
                <el-table-column prop="startTime" label="竞拍开始时间" width="200" value-format="yyyy-MM-dd HH:mm:ss">
              </el-table-column>
              <el-table-column prop="endTime" label="竞拍截止时间" width="200" value-format="yyyy-MM-dd HH:mm:ss">
              </el-table-column>
                <el-table-column prop="number" label="数量">
                </el-table-column>
                <el-table-column prop="weight" label="重量">
                </el-table-column>
                <el-table-column prop="earnestMoney" label="保证金">
                </el-table-column>
                <el-table-column prop="back" label="备注">
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="350px">
                    <template slot-scope="scope">
                      <el-button  type="danger" size="medium" plain @click="information (scope.row)">详情</el-button>
                      <!-- id=erShen v-if判断条件：（4）是二审待审合 (5) 二审通过 (6) 二审驳回 -->
                      <el-button
                      id="erShen"
                      size="medium"
                      style="background-color: #34262c; color: #fff"
                      plain
                      @click="goodsInfoUpdatePass2(scope.row.id)"
                      v-if="scope.row.checkStatus === 4 || scope.row.checkStatus !== 5" >二审核通过</el-button>
                      <!-- id=erShen v-if判断条件：（4）是二审待审合 (5) 二审通过 (6) 二审驳回 -->
                      <el-button id=erShenbohui type="danger" style="background-color: #d7000f; color: #fff"
                      size="medium" plain @click="goodsInfoUpdateReject (scope.row.id)"
                      v-if="scope.row.checkStatus !== 6 || scope.row.checkStatus === 4|| scope.row.checkStatus === 5">二审驳回</el-button>
                      <!--  v-if判断条件：跳转竞拍跟踪页面 -->
                      <el-button  type="danger" style="background-color: #34262c; color: #fff" size="medium" plain @click="getStageInfo(scope.row.id)" v-if="scope.row.checkStatus == 5">竞拍跟踪</el-button>
                      </template>
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page.pageNum"
                :page-sizes="[5, 10, 15, 20]" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="page.total"
                style="float:right;margin-right: 40%;">
            </el-pagination>
        </el-card>
        <!-- 驳回弹窗 -->
        <el-dialog title="提示" :visible.sync="goodsInfoUpdateReject1" width="30%">
          <div>您的信息不符合。。。。</div>
          <el-button @click="goodsInfoUpdateReject1 = false">取 消</el-button>
            <el-button type="primary" @click="goodsInfoUpdateReject11()">确 定</el-button>
        </el-dialog>
        <!-- 详情弹窗 -->
        <el-dialog title="提示" :visible.sync="information1" width="30%">
          <el-form ref="list" :model="list" label-width="80px">
                      <el-form-item label="竞拍编号">
                          <el-input v-model="list.goodsNumber"></el-input>
                      </el-form-item>
                      <el-form-item label="状态">
                          <el-input v-model="list.checkStatus"></el-input>
                      </el-form-item>
                      <el-form-item label="拍品名称">
                          <el-input v-model="list.goodsName"></el-input>
                      </el-form-item>
                      <el-form-item label="联系人">
                          <el-input v-model="list.contactName"></el-input>
                      </el-form-item>
                      <el-form-item label="联系方式">
                          <el-input v-model="list.phone"></el-input>
                      </el-form-item>
                      <el-form-item label="开始时间">
                          <el-input v-model="list.startTime" ></el-input>
                      </el-form-item>
                      <el-form-item label="截止时间">
                          <el-input v-model="list.endTime"></el-input>
                      </el-form-item>
                      <el-form-item label="数量">
                          <el-input v-model="list.number"></el-input>
                      </el-form-item>
                      <el-form-item label="重量">
                          <el-input v-model="list.weight"></el-input>
                      </el-form-item>
                      <el-form-item label="保证金">
                          <el-input v-model="list.earnestMoney"></el-input>
                      </el-form-item>
                      <el-form-item label="备注">
                          <el-input v-model="list.back"></el-input>
                      </el-form-item>
          </el-form>
              <el-button type="small" @click="information1=false">关闭</el-button>
        </el-dialog>
    </div>
  </template>

<script>
export default {
  data () {
    return {
      // 状态判断
      status:
        [
          {
            id: 1,
            value: '待审合'
          },
          {
            id: 2,
            value: '一审通过'
          },
          {
            id: 3,
            value: '一审驳回'
          },
          {
            id: 4,
            value: '二审待审批'
          },
          {
            id: 5,
            value: '二审通过'
          },
          {
            id: 6,
            value: '二审驳回'
          }
        ],
      options: [{
        value: 1,
        label: '待审合'
      }, {
        value: 2,
        label: '一审通过'
      }, {
        value: 3,
        label: '一审驳回'
      }, {
        value: 4,
        label: '二审待审批'
      }, {
        value: 5,
        label: '二审通过'
      }, {
        value: 6,
        label: '二审驳回'
      }],
      value: '',
      input: '',
      value1: '',
      tableData: [], // 全查
      information1: false, // 详情弹窗
      queryGoodsInfoSelectAll: {
        contactName: '',
        phone: '',
        checkStatus: '',
        time: [],
        startTime: '',
        endTime: ''
      },
      page: {
        total: 0, // 数据总条数
        pageNum: 1, // 当前页
        pageSize: 5// 每页条数
      },
      tableFrom: [],
      id: '', // 获取修改状态id
      list: {},
      goodsInfoUpdateReject1: false // 修改驳回弹窗
    }
  },
  mounted () {
    this.getpublishSelectAll() // 初始化
  },
  methods: {
    getStageInfo (data) {
      this.$router.push({ name: 'SysStage', params: { id: data } })
    },
    goodsInfoUpdateReject (data) {
      this.goodsInfoUpdateReject1 = true
      this.id = JSON.parse(JSON.stringify(data))
    },
    // // 驳回弹窗
    goodsInfoUpdateReject11 (id) {
      this.$axios
        .get('http://127.0.0.1:8088/GoodsInfo/goodsInfoUpdateRejectSecondary', {
          params: {
            id: this.id
          }
        }
        )
        .then((res) => {
          if (res.data.obj > 0) {
            this.message('恭喜你，审核成功！', 'success')
            // 关闭修改窗口
            this.goodsInfoUpdateReject1 = false
            // 初始化菜单信息
            this.getpublishSelectAll()
          } else {
            this.message('对不起，驳回失败！', 'warning')
          }
        }).catch(err => {
          console.log(err)
        })
    },
    // 审核弹窗
    goodsInfoUpdatePass2 (id) {
      this.$confirm('该信息审核已通过!', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios
          .get('GoodsInfo/goodsInfoUpdateSecondary', {
            params: {
              id: id
            }
          }
          )
          .then((res) => {
            if (res.data.obj > 0) {
              // 初始化菜单信息
              this.getpublishSelectAll()
            }
          })
        this.$message({
          type: 'success',
          message: '审核已通过!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '审核已取消'
        })
      }).catch(err => {
        console.log(err)
      })
    },
    getpublishSelectAll () { // 查询
      if (this.queryGoodsInfoSelectAll.time != null) {
        this.queryGoodsInfoSelectAll.startTime = this.queryGoodsInfoSelectAll.time[0]
        this.queryGoodsInfoSelectAll.endTime = this.queryGoodsInfoSelectAll.time[1]
      }
      this.$axios.get('/GoodsInfo/goodsInfoSelectAll', { // 链接后端
        params: {
          contactName: this.queryGoodsInfoSelectAll.contactName,
          phone: this.queryGoodsInfoSelectAll.phone,
          checkStatus: this.queryGoodsInfoSelectAll.checkStatus,
          startTime: this.queryGoodsInfoSelectAll.startTime,
          endTime: this.queryGoodsInfoSelectAll.endTime,
          pageNum: this.page.pageNum, // 当前页
          pageSize: this.page.pageSize // 每页条数
        }
      }).then(res => {
        if (res.data.flag) {
          this.tableData = res.data.obj.content
          this.page.total = res.data.obj.total
        }
      }).catch(err => {
        this.myMessage('error', err)
      })
    },
    /* 搜索栏重置按钮 */
    resetting () {
      this.queryGoodsInfoSelectAll.contactName = ''
      this.queryGoodsInfoSelectAll.phone = ''
      this.queryGoodsInfoSelectAll.checkStatus = ''
      this.queryGoodsInfoSelectAll.time = []
    },
    handleSizeChange (val) {
      this.page.pageSize = val
      this.getpublishSelectAll()
    },
    handleCurrentChange (val) {
      this.page.pageNum = val
      this.getpublishSelectAll()
    },
    // 弹窗详情
    information (data) {
      this.tableFrom = data
      this.list = JSON.parse(JSON.stringify(data))
      this.information1 = true
    }
  }
}
</script>

  <style scoped>
.box-card2{
    width: 100%;
    height: 900px;
}
  </style>
